
import type { PagesType } from '@/router/types/pages';
import type { CustomShareOptions } from '../hooks/useCustomShare';
import type { CustomNavigateToOptions } from '@/router/types/nav';

export enum CustomShareTypeEnum {
  /** 小程序分享 */
  SHARE = 'share',
  /** 海报 */
  POSTER = 'poster',
  /** 分享朋友圈 */
  TIME_LINE = 'timeline',
  /** 复制链接 */
  COPY_LINK = 'copyLink',
  /** 插入公众号 */
  INSERT_OFFIACCOUNT = 'insertOffiaccount',
  /** 关注公众号 */
  OFFIACCOUNT = 'offiaccount',
  /** 站内链接 */
  INTERNAL_LINKS = 'internalLinks',
  /** 下载小程序码 */
  DOWNLOAD_MINIPROGRAM_CODE = 'downloadMiniprogramCode'
}

export interface ShareBtnItem {
  icon: string
  text: string
  type: `${CustomShareTypeEnum}`
}

export interface WxShareOptions {
  /** 分享路径 */
  path: PagesType | string
  /** 分享图片 */
  imageUrl?: string
  /** 分享标题 */
  title?: string
  /** 画板数据(通过画板生成分享图) */
  board?: PainterBoard
}

export type ReturnWxShareOptions = Omit<WxShareOptions, 'board'>

export interface CustomShareActionType {
  setButtons: (buttons: CustomShareOptions['buttons']) => void
  setDisableds: (disableds: CustomShareOptions['disableds']) => void
  /** 设置微信分享的参数 */
  setWxShareOptions: (options: WxShareOptions[]) => Promise<ReturnWxShareOptions[]>
  /** 单独设置微信右上角菜单分享的参数 */
  setMenuWxShareOptions: (options: WxShareOptions) => void
  /** 获取当前选中的微信分享的参数 */
  getCurrentWxShareOptions: () => ReturnWxShareOptions
  /** 设置海报绘制数据 */
  setPosterDrawData: (data: PainterBoard[] | string[]) => Promise<string[]>
  /** 设置分享朋友圈的参数 */
  setShareTimelineContent: (options: Page.ShareTimelineContent) => void
  /** 设置分享日志的ID, 用于"插入公众号"和"复制链接" */
  setShareLogId: (id: number) => void
  /** 设置内部链接的参数 */
  setInternalLinkOptions: <T extends PagesType>(options: CustomNavigateToOptions<T>) => void
  /** 设置下载小程序码的参数 */
  setMiniprogramCode: (codeImg: string) => void
}

export type RegisterFn = (instance: CustomShareActionType) => void;

export type UseCustomShareReturnType = [RegisterFn, CustomShareActionType];

export type WxLink = 'ShortLink' | 'URLLink'

export interface CopyLinkItem {
  type: WxLink
  text: string
  tips: string
  img: string
}